/** @format */

/**
 *@desc: 水环境工具类
 *@author: ptt
 *@date 2023/12/18
 */
const handleVal = (type, val, resType) => {
    let color = '';
    let text = '';
    let textLevel = '';
    let num = 0;
    // 地表水
    if (type == 'DBS') {
        switch (val) {
            case '1':
            case 1:
            case 'Ⅰ':
            case 'Ⅰ类':
            case 'Ⅰ类水':
            case '一类':
                color = '#44c5fd';
                text = '优';
                textLevel = 'Ⅰ类';
                num = 1;
                break;
            case '2':
            case 2:
            case 'Ⅱ':
            case 'Ⅱ类':
            case 'Ⅱ类水':
            case '二类':
                color = '#51a5fd';
                text = '优';
                textLevel = 'Ⅱ类';
                num = 2;
                break;
            case '3':
            case 3:
            case 'Ⅲ':
            case 'Ⅲ类':
            case 'Ⅲ类水':
            case '三类':
                color = '#73bb31';
                text = '良';
                textLevel = 'Ⅲ类';
                num = 3;
                break;
            case '4':
            case 4:
            case 'Ⅳ':
            case 'Ⅳ类':
            case 'Ⅳ类水':
            case '四类':
                color = '#eebd15';
                text = '轻度';
                textLevel = 'Ⅳ类';
                num = 4;
                break;
            case '5':
            case 5:
            case 'Ⅴ':
            case 'Ⅴ类':
            case 'Ⅴ类水':
            case '五类':
                color = '#f88e17';
                text = '中度';
                textLevel = 'Ⅴ类';
                num = 5;
                break;
            case '6':
            case 6:
            case '劣Ⅴ':
            case '劣Ⅴ类':
            case '劣Ⅴ类水':
            case '劣五类':
                color = '#ee3b5b';
                text = '重度';
                textLevel = '劣Ⅴ类';
                num = 6;
                break;

            default:
                color = '#b0b0b0';
                text = '-';
                textLevel = '-';
                num = 0;
                break;
        }
    }
    // 海水
    if (type == 'HS') {
        switch (val) {
            case '1':
            case 1:
            case 'Ⅰ':
            case 'Ⅰ类':
            case 'Ⅰ类水':
            case '一类':
                color = '#68a0cd';
                text = '优';
                textLevel = 'Ⅰ类';
                num = 1;
                break;
            case '2':
            case 2:
            case 'Ⅱ':
            case 'Ⅱ类':
            case 'Ⅱ类水':
            case '二类':
                color = '#9ecde7';
                text = '良';
                textLevel = 'Ⅱ类';
                num = 2;
                break;
            case '3':
            case 3:
            case 'Ⅲ':
            case 'Ⅲ类':
            case 'Ⅲ类水':
            case '三类':
                color = '#b4a79e';
                text = '轻度';
                textLevel = 'Ⅲ类';
                num = 3;
                break;
            case '4':
            case 4:
            case 'Ⅳ':
            case 'Ⅳ类':
            case 'Ⅳ类水':
            case '四类':
                color = '#948173';
                text = '中度';
                textLevel = 'Ⅳ类';
                num = 4;
                break;
            case '5':
            case 5:
            case 'Ⅴ':
            case 'Ⅴ类':
            case 'Ⅴ类水':
            case '劣四类':
                color = '#726151';
                text = '重度';
                textLevel = '劣Ⅳ类';
                num = 5;
                break;

            default:
                color = '#ccc';
                text = '-';
                textLevel = '-';
                num = 0;
                break;
        }
    }

    if (resType == 'color') {
        return color;
    } else if (resType == 'text') {
        return text;
    } else if (resType == 'textLevel') {
        return textLevel;
    } else if (resType == 'num') {
        return num;
    }
};

const waterObj = {
    // 不同水质对应的颜色
    setColor: (type, val) => {
        return handleVal(type, val, 'color');
    },
    // 不同水质对应的等级文字
    setText: (type, val) => {
        return handleVal(type, val, 'text');
    },
    // 数字等级转汉字等级
    numToCharacter: (type, val) => {
        return handleVal(type, val, 'textLevel');
    },
    // 水质类别转数字（一般用于数值轴的echarts)
    characterToNum: (type, val) => {
        return handleVal(type, val, 'num');
    }
};

export default waterObj;
